//柱状图模块1
// 左上 居家照护服务机构街镇服务情况
(function () {
    $.ajax({
        url:"../statistics/kkfw",
        type:"post",
        dataType:"json",
        success:function (data){
            //1.实例化对象
            var myChart =echarts.init(document.querySelector('#basic_statistics'));
            //2.指定配置项和数据
            var option = {

                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    //修改图例的位置
                    orient: 'vertical',
                    left: 'left',
                    //修改小图标的大小
                    itemWidth:10,
                    itemHeight:10,
                    textStyle:{
                        color :"rgba(255,255,255,0.7)",
                        fontSize: fontSize(0.12),
                    },
                    left: 'left',
                    bottom:"0%"
                },
                series: [
                    {
                        name: '服务机构街镇服务人数',
                        type: 'pie',
                        radius: '55%',
                        center:["60%","60%"],
                        //图形标签
                        label:{
                            show:true,
                            textStyle:{
                                color :"rgba(255,255,255,0.7)",
                                fontSize: fontSize(0.12),

                            },

                        },

                        data: data,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };
            //3.把配置项给实例对象
            myChart.setOption(option);

            //4、让图表自适应屏幕
            window.addEventListener("resize",function () {
                    myChart.resize();
                }
            )
        }
    })


})();


function fontSize(res){
    let docEl = document.documentElement,
        clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
    if (!clientWidth) return;
    let fontSize = 100 * (clientWidth / 2080);
    return res*fontSize;
}



